package com.jee.ssm.modules.ssm.controller;




import com.github.pagehelper.PageInfo;
import com.jee.ssm.model.Banner_Class;
import com.jee.ssm.model.param.ParamMap;
import com.jee.ssm.modules.ssm.services.Banner_ClassService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;


@Controller
@RequestMapping(value="/test")
public class TestController extends AdminBaseController {

    /**
     * 轮播测试
     */
    @RequestMapping(value = "/demo")
    public String demo() throws Exception {
        return "manager/index1";
    }
    /**
     * 获取用户列表 分页
     *
     * @param request 请求参数
     * @return 用户列表页面
     * @throws Exception 获取用户列表失败
     */
    @RequestMapping(value = "/list")
    public ModelAndView list(HttpServletRequest request) throws Exception {

        ParamMap paramMap = new ParamMap(request);
        PageInfo<Banner_Class> pageInfo = banner_classService.list(paramMap, 1, 10);

        paramMap.put("pageInfo", pageInfo);
        return new ModelAndView("manager/banner/bannerlist", paramMap);
    }

    /**
     * 进入轮播页面
     *
     * @param model 返回用户的容器
     * @param id    用户id
     * @return 编辑页面
     * @throws Exception 进入编辑页面失败
     */
    @RequestMapping(value = "/lunbo")
    public ModelAndView edit(ModelMap model, @RequestParam String id) {
        try {
            model.put("data", banner_classService.selectById(id));
            System.out.println(banner_classService.selectById(id).getClassname());//检查值是否存在

        } catch (Exception e) {
            e.printStackTrace();
        }
        return new ModelAndView("manager/banner/Banner", model);
    }

    /**
     * 根据 id 查找用户
     * @param id 用户id
     * @return 用户对象 jsonj
     * @throws Exception 查找用户失败
     */
    @RequestMapping(value="/findJson")
    @ResponseBody
    public Banner_Class find(@RequestParam String id) {
        return banner_classService.selectById(id);
    }






    //----------------------------- property ----------------------------------
    @Resource
    private Banner_ClassService banner_classService;









}
